﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Maticsoft.Web
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_login_Click(object sender, EventArgs e)
        {

            Maticsoft.BLL.studentInfo sm = new BLL.studentInfo();

            string stuNum = this.txt_kh.Text;
            string stuName = this.txt_name.Text;

            if (string.IsNullOrEmpty(stuName))
            {
                Maticsoft.Common.MessageBox.Show(this, "请填写考生姓名！");
                return;
            }
            if (string.IsNullOrEmpty(stuNum))
            {
                Maticsoft.Common.MessageBox.Show(this, "请填写考号！");
                return;
            }

            DataSet ds = sm.GetList(" and stuNum='" + stuNum + "' and stuName='" + stuName + "'");

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["state"].ToString() != "1")
                {
                    Session["login"] = ds.Tables[0].Rows[0]["stuId"].ToString() + "|stu";
                    HttpCookie acookie = new HttpCookie("stuId");
                    acookie.Value = ds.Tables[0].Rows[0]["stuId"].ToString();
                    acookie.Expires = DateTime.MaxValue;
                    Response.Cookies.Add(acookie);
                    Response.Redirect("Frame.aspx");
                }
                else
                {
                    Maticsoft.Common.MessageBox.Show(this, "您已考过！");

                }
            }
            else
            {
                Maticsoft.Common.MessageBox.Show(this, "考号、姓名出错！");
            }
        }

        protected void btn_re_Click(object sender, EventArgs e)
        {
            this.txt_name.Text = "";
            this.txt_kh.Text = "";

        }
    }
}
